/**
 * 
 */
package com.android.cherryboard.Adapters;

import java.util.ArrayList;

import com.android.cherryboard.R;
import com.android.cherryboard.Deshboard.CherryboardListData;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

/**
 * @author ashu
 *
 */
public class CherryboardListAdapter extends BaseAdapter {

	private ArrayList<CherryboardListData> result;
	private LayoutInflater inflater;
	public CherryboardListAdapter(Context context,
			ArrayList<CherryboardListData> result) {
		// TODO Auto-generated constructor stub
		this.result = result;
		this.inflater = LayoutInflater.from(context);
	}
	
	
	

	/* (non-Javadoc)
	 * @see android.widget.Adapter#getCount()
	 */
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return result.size();
	}

	/* (non-Javadoc)
	 * @see android.widget.Adapter#getItem(int)
	 */
	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return result.get(position);
	}

	/* (non-Javadoc)
	 * @see android.widget.Adapter#getItemId(int)
	 */
	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	/* (non-Javadoc)
	 * @see android.widget.Adapter#getView(int, android.view.View, android.view.ViewGroup)
	 */
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		
		ViewHolder holder;
		if (convertView == null) {
			holder = new ViewHolder();
			
			convertView = inflater.inflate(R.layout.cherryboard_list_row_veiw, null);
			
			holder.tvCherryboardTitle = (TextView)convertView.findViewById(R.id.textView_cherrybord_list_row_view_title);
		
			convertView.setTag(holder);
			
		} else {

			holder = (ViewHolder)convertView.getTag();
		}
		
		CherryboardListData chereyboardData = result.get(position);
		holder.tvCherryboardTitle.setText(chereyboardData.getCherryboard_title());
		
		return convertView;
	}
	class ViewHolder{
		TextView tvCherryboardTitle;
		
	}

}
